#! /bin/bash

mkdir -p ${Titan_path}/allModel/
mkdir -p ${Titan_path}/CheckModel/

## 一个样本的所有模型都考虑
cat ${list_file} | grep -v Tumor | awk -F, '{print $1}' | sort -u | xargs -P 20 -i sh -c '
echo {}
${titianCNA_rscript} ${scripts_path}/TitanCNA_getAllModel.R \
--ploidyRun2 ${Titan_path}/hmm/{}_titanCNA_ploidy2 \
--ploidyRun3 ${Titan_path}/hmm/{}_titanCNA_ploidy3 \
--ploidyRun4 ${Titan_path}/hmm/{}_titanCNA_ploidy4 \
--outFile ${Titan_path}/allModel/{}_allModel_params.tsv
'

## 所有模型合并到一个文件夹
rm -rf ${Titan_path}/allModel/All_allModel_params.tsv
cat ${Titan_path}/allModel/*_allModel_params.tsv | head -1 > ${Titan_path}/allModel/All_allModel_params.tsv
for Tumor in `cat ${list_file} | grep -v Tumor | awk -F, '{print $1}' | sort -u `
do
cat  ${Titan_path}/allModel/${Tumor}_allModel_params.tsv | sed '1d' >> ${Titan_path}/allModel/All_allModel_params.tsv  
done
